<nav class="navbar fixed-top navbar-dark ad-nav-bar navbar-expand-lg bg-default">
    <div class="container">
        <a class="navbar-brand" href="">
			<img src="upload/images/logo.png" class="img-fluid" alt="">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul id="menu" class="nav navbar-nav">
            	<c:forEach var="level1Menu" items="${rootMenu.children}">
            	<c:choose>
            		<c:when test="${level1Menu.children==null}">
	            		<li <c:if test="${level1Menu.attr1!=''}">data-menuanchor="${level1Menu.attr1}"</c:if> class="nav-item">
		                    <a menuId="${level1Menu.id}" menuCode="${level1Menu.code}" class="nav-link" href="${level1Menu.url}" ><span>${level1Menu.name}</span></a>
		                </li>
            		</c:when>
            		<c:otherwise>
            			<li <c:if test="${level1Menu.attr1!=''}">data-menuanchor="${level1Menu.attr1}"</c:if> class="nav-item dropdown">
		                    <a class="nav-link dropdown-toggle" href="${level1Menu.url}" menuId="${level1Menu.id}"
		                       id="${level1Menu.code}" data-toggle="dropdown" onclick="document.location.href='${level1Menu.url}'"
		                       aria-haspopup="true" aria-expanded="false">
		                       <span>${level1Menu.name}</span>
		                    </a>
		                    <ul class="dropdown-menu" aria-labelledby="${level1Menu.code}">
		                    	<c:forEach var="level2Menu" items="${level1Menu.children}">
		                        <li><a class="dropdown-item" href="${level2Menu.url}" menuId="${level2Menu.id}">${level2Menu.name}</a></li>
		                        </c:forEach>
		                    </ul>
		                </li>
            		</c:otherwise>
            	</c:choose>
            	</c:forEach>
            </ul>
        </div>
    </div>
</nav>
<script>
function fixMenu(){
	$('#menu a').each(function(){
		var href = $(this).attr('href');
		var menuId = $(this).attr('menuId');
		if(href.indexOf('#')<0 && href.indexOf('curMenuId')<0 && href.indexOf('info/list')<0) {
			if(href.indexOf('?')>=0) {
				href += '&curMenuId=' + menuId;
			}
			else {
				href += '?curMenuId=' + menuId;
			}
		}
		$(this).attr('href', href);
	})
}
fixMenu();
</script>